/**
 * @description: 控制页面滚动
 * @param {*} show
 * @returns
 */
import { watchEffect } from "vue";

export const useOverflow = show => {
  const canScroll = () => {
    document.querySelector(".scrollable").style.overflow = "auto";
  };
  const noScroll = () => {
    document.querySelector(".scrollable").style.overflow = "hidden";
  };

  watchEffect(() => {
    console.log("watchEffect监听弹窗状态" + show.value);

    if (show.value) {
      noScroll();
    } else {
      canScroll();
    }
  });

  return { canScroll, noScroll, show };
};
